<template>
  <div class="grand-child">
    <h3>我是孙组件</h3>
  <div>银子:{{ money }}</div>
  <div>有一辆{{ car.brand }}车，价值：{{ car.price }}万</div>
  <button @click="updateMoney(3)">花爷爷的钱</button>
  </div>
</template>

<script setup lang="ts" name="GrandChild">
  import { inject } from "vue";
let {money,updateMoney}=inject("moneyContext",{money:100,updateMoney:(x:number)=>{}})
let car=inject("car",{brand:"未知",price:0})
</script>

<style scoped>
  .grand-child{
    background-color: orange;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px black;
  }
</style>